﻿@using BI.CF.PageList
@using BI.CF.Model
@model BI.CF.PageList.Pager<LoginRecordModel>
@{
    ViewBag.Title = "View_UserIpShow";
    Layout = "~/Views/Shared/MyAccount.cshtml";
}
@{
    BI.CF.PageList.Pager<LoginRecordModel> m = Model as BI.CF.PageList.Pager<LoginRecordModel>;
    var Uid = Session["UserID"];
}

    <div>
        选择时间：<input id="Text1" type="date" />---<input id="Text2" type="date" />
        登录状态：<select id="State" name="resultType">
            <option value="" selected='selected'>全部</option>
            <option value="正常登录">正常登录</option>
            <option value="登录密码错误">登录密码错误</option>
        </select>
        <input id="Button1" style="float:right;margin-right:250px;" type="button" class="Flat_but" onclick="sousuos()" value="搜索" />
        <table cellspacing="0" cellpadding="0" style=" width:100%; font-size:12px;" class="table_list" id="table_IP_Show"></table>
        <table cellspacing="0" cellpadding="0" style=" width:100%; font-size:12px;" class="table_list" id="tass"></table>
    </div>
<link href="~/Content/BootstrapSouce/css/bootstrap.min.css" rel="stylesheet" />
<script src="~/Content/BootstrapSouce/js/jquery.js"></script>
<script src="~/Content/BootstrapSouce/js/bootstrap.min.js"></script>
<script src="~/Scripts/jquery-1.8.2.min.js"></script>
<script>

    //首次加载
    $(function () {
        Page(1);
    });
    function Page(i) {
        //显示加搜索加分页
        var DateMin = $("#Text1").val();
        var DateMax = $("#Text2").val();
        var State = $("#State").val();
        $.getJSON("/MyAccount/View_UserIPShow3", {
            datemin: DateMin,
            datemax: DateMax,
            state: State,
            pageindex: i,
            pagesize: 10
        }, function (data)
        {
            var str = "<tr><th style='width:150px;'>IP地址</th><th style='width:250px;'>登录城市</th><th style='width:250px;'>登录时间</th><th style='width:200px;'>登陆状态</th></tr>";
            for (var i = 0; i < data.Data.length; i++) {
                str += "<tr><td>" + data.Data[i].LIP + "</td>";
                str += "<td><a style='color:blue;' href='http://www.baidu.com/s?wd= " + data.Data[i].LIP + "' >百度查询IP所在地</a></td>";
                str += "<td>" + ChangeDateFormat(data.Data[i].LTime) + "</td>";
                str += "<td>" + data.Data[i].OperationRsult + "</td></tr>";
                $("#table_IP_Show").html(str);
            }
            
            counttt = data.PageCount;
            var tas = "<tr style='background-color:#eddede';><td><span> 共<label id='sums' >" + data.PageCount + "</label>  页&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp &nbsp&nbsp&nbsp&nbsp当前第 <label id='index'>" + data.PageIndex + "</label> 页&nbsp&nbsp&nbsp&nbsp <a onclick='Page(1)' style='cursor:pointer;'>首页</a>&nbsp&nbsp&nbsp&nbsp";
            //判断当前页是否为1，如果不是那就减一如果是那就直接定到第一页
            if (data.PageIndex <= 1) {
                tas += ("<a  onclick='Page(1)' style='cursor:pointer;' >上一页</a>&nbsp&nbsp&nbsp&nbsp");
            }
            else {
                tas += ("<a  onclick='Page(" + (data.PageIndex - 1) + " )' style='cursor:pointer;' >上一页</a>&nbsp&nbsp&nbsp&nbsp");
            }
            //判断是否为最后一页。如果不是那就加一如果是那就直接定到最后一页
            if (data.PageIndex >= data.PageCount) {
                tas += "<a  onclick='Page(" + (data.PageCount) + " )' style='cursor:pointer;' >下一页</a>&nbsp&nbsp&nbsp&nbsp";
            } else {
                tas += "<a  onclick='Page(" + (data.PageIndex + 1) + ")' style='cursor:pointer;' >下一页</a>&nbsp&nbsp&nbsp&nbsp";
            }
            tas += " <a onclick='Page(" + data.PageCount + ")' style='cursor:pointer;'>尾页</a>&nbsp&nbsp&nbsp&nbsp";

            //跳转页
            tas += "转到&nbsp<input id='pageas' style='width:30px' type='text' />&nbsp&nbsp<input id='Button22' type='button'  style='cursor:pointer;'  onclick='tiaozhuan()'  value='确定' /></span></td> </tr>";
            $("#tass").html(tas);
        });
    };
    //跳转分页
    function tiaozhuan() {
        var idd = $("#pageas").val();
        if (idd > counttt) {
            alert("您输入的页数到达极限！为您跳转到尾页");
            Page(counttt);
        } else {
            Page(idd);
        }
    };
    //搜索
    function sousuoget() {
        $("#startime").val("");//清空开始时间
        $("#endtime").val("");//清空结束时间
        Page(1);
    }
    function sousuos() {
        Page(1);
    }

</script>